<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta charset="utf-8">
    <!--[if IE]>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Page title -->
    <title>Petz - Pet HTML5 Template</title>
    <!--[if lt IE 9]>
    <script src="${pageContext.request.contextPath}/foreground/js/respond.js"></script>
    <![endif]-->
    <!-- Bootstrap Core CSS -->
    <link href="${pageContext.request.contextPath}/foreground/css/bootstrap.css" rel="stylesheet" type="text/css">
    <!-- Icon fonts -->
    <link href="${pageContext.request.contextPath}/foreground/fonts/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/foreground/fonts/flaticons/flaticon.css" rel="stylesheet" type="text/css">
    <link href="${pageContext.request.contextPath}/foreground/fonts/glyphicons/bootstrap-glyphicons.css" rel="stylesheet" type="text/css">
    <!-- Google fonts -->
    <link href="https://fonts.googleapis.com/css?family=Lato:400,800" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css?family=Baloo+Thambi" rel="stylesheet">
    <!-- Style CSS -->
    <link href="${pageContext.request.contextPath}/foreground/css/style.css" rel="stylesheet">
    <!-- Plugins CSS -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/foreground/css/plugins.css">
    <!-- Color Style CSS -->
    <link href="${pageContext.request.contextPath}/foreground/styles/maincolors.css" rel="stylesheet">

    <script src="${pageContext.request.contextPath}/background/js/jquery.min.js"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/background/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/background/js/xadmin.js"></script>
</head>
<body>
    <section id="contact" class="pages no-padding">
    <!-- 最中间的那个蓝色椭圆标题 -->
    <div class="jumbotron" data-stellar-background-ratio="0.5">
        <div class="jumbo-heading" data-stellar-background-ratio="1.2">
            <h1>用户登录</h1>
        </div>
    </div>

    <!-- container -->
    <div class="container">
        <div class="row">
            <div class="col-lg-6 col-md-6 col-lg-offset-1 col-md-offset-1 res-margin">
                <h3>发布公告</h3>
                <!-- Form Starts -->

                <form id="ggg" action="AddMessage" enctype="multipart/form-data" method="post">
                    <div class="form-group">
                        <label>用户名<span class="required">*</span></label>
                        <input type="text" value="${userid}" name="msgUserid" class="form-control input-field" required="" readonly="readonly">
                        <label>当前时间</label>
                        <input type="text" value="${time}" name="msgTime" class="form-control input-field" required="" readonly="readonly">
                        <label>公告标题</label>
                        <input type="text" name="msgTitle" class="form-control input-field" required="">
                        <label>联系电话</label>
                        <input type="text" name="msgPhone" class="form-control input-field" required="">
                        <label>公告内容</label>
                        <textarea name="msgText" id="text" class="textarea-field form-control" rows="3"  required=""></textarea>
                        <label>上传图片</label>
                        <input type="file" name="Img" class="form-control input-field" required="">

                    </div>
                    <div style="display: flex;flex-direction: row;">
                        <button  type="button" onclick="addMessage()" class="btn center-block" >提交</button>
                    </div>
                </form>

                <div id="contact_results"></div>
            </div>
        </div>
    </div>
    <div class="container-fluid margin1">
    </div>
</section>

<script>
    layui.use(['form','layer','jquery'], function() {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        window.addMessage=function(){
            $ = layui.jquery;
            var layer = layui.layer;
            var formData=new FormData($("#ggg")[0]);
            //监听提交
            $.ajax({
                type:'POST',
                url:'AddMessageAuditing',
                data:formData,
                async: false,
                contentType: false,
                processData: false,
                //等待返回值
                success:function(result){
                    if(result=="SUCCESS"){
                        layer.confirm('添加成功',{icon: 6},function(index){
                            // 获得frame索引
                            var index = parent.layer.getFrameIndex(window.name);
                            //关闭当前frame
                            parent.layer.close(index);
                            //刷新我的 双亲页面 classobjlist.jsp
                            window.parent.location.reload();                        })
                    }
                    else{
                        layer.alert(result,{title:"添加失败"});
                    }
                }
            });
            return false;
        }


    })
</script>
</body>
</html>
